'use strict'
const { Client } = require('pg')
// 人大金仓数据库连接封装
const CLASS = function() {
    try {
        // 创建数据库连接
        this.client = new Client({
            user: 'BIG-SCREEN',
            host: '192.168.2.115',
            // database: 'BIG-SCREEN',
            password: '123456',
            port: 5236
        })
        this.client.connect()
    } catch (err) {
        throw new Error('createRDPool error: ' + err.message)
    }
}

CLASS.prototype = {
    // 封装查询数据以及数据处理返回
    async select(sql) {
        const res = await this.client.query(sql)
        return res.rows
    }
}
module.exports = CLASS
